; Test to verify the array buffer overrun vulnerability has been fixed

(print "Testing if array vulnerability fix works...")

; Create malicious byte array claiming to be a 100-byte array
; but only containing 8 bytes of actual data
(define exploit-data [
  0x0D          ; S_LBM_ARRAY type tag
  0x00 0x00 0x00 0x64  ; Size: claims 100 bytes (0x64 = 100)
  0xAA 0xBB 0xCC 0xDD  ; Only 4 bytes of actual data
])

; Attempt to unflatten - this should now fail due to bounds checking
(define result (trap (unflatten exploit-data)))

(if (or (eq (car result) 'exit-error)
        (and (eq (car result) 'exit-ok) (eq (car (cdr result)) nil)))
    (print "SUCCESS")
    {
        (print "FAILURE: Array vulnerability still exists")
        (define created-array (car (cdr result)))
        (print "Created array:" created-array)
        (print "Array length:" (buflen created-array))
    })